--等待角色指令
local FightBehavior = require("gameLogic.fight.fightBehavior.FightBehavior")
local WaitBehavior = class("WaitBehavior", FightBehavior)

function WaitBehavior:ctor()
    WaitBehavior.super.ctor(self)
end

function WaitBehavior:excute(battleReport)
    self._battleReport = battleReport
    local entitySkills = self._entity:getAllSkills()
    local param = {}
    param.entityId = self._entity:getId()
    param.skills = entitySkills
    G_SignalManager:dispatch(SignalConst.EVENT_REQUEST_USER_SKILL, param)
    G_SignalManager:addOnce(SignalConst.EVENT_RECEIVE_USER_SKILL, handler(self, self._onEventWait))
end

function WaitBehavior:_onEventWait(id, param)
    local skillId = param.skillId
    local entityId = param.targetEntityId
    -- printDebug("选中 " .. skillId .. " entityId=" .. entityId)
    local skill = self._entity:getSkillById(skillId)
    local target = skill:getTarget()

    local entitys = {}
    if entityId then
        entitys = self:getSkillTargetEntityUser(target, skill, entityId)
    else
        entitys = self:getSkillTargetEntity(target, skill)
    end
    self._battleReport:addAttackSkillId(skill:getId())
    skill:actOn(entitys, self._battleReport)
    self._entity:dispatchActionEnd()
end

return WaitBehavior
